'''
binary_research is very important,just try to understand this principle design
this little algorithm is try to find the index of item by use time shorter
and the list must be sorted
'''


def binary_search(list,item):
    low = 0
    hight = len(list)-1
    while low <= hight:
        mid = (low + hight)/2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            hight =mid -1
        else:
            low = mid +1
    return None
my_list = [1,4,5,8,20,40,42,45]

print binary_search(my_list,20)
